package com.comm.db.dao;

import org.hibernate.Session;

import com.comm.db.SessionFactory;

/**
 * Data access object (DAO) for domain model
 * 
 * @author MyEclipse Persistence Tools
 */
public class BaseHibernateDAO implements IBaseHibernateDAO {
	public void saveOrUpdate(Object obj) {

		try {
			Session session = SessionFactory.getSession();
			session.beginTransaction();
			session.saveOrUpdate(obj);
			session.beginTransaction().commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			SessionFactory.closeSession();
		}

	}

	public void update(Object obj) {

		try {
			Session session = SessionFactory.getSession();
			session.beginTransaction();
			session.update(obj);
			session.beginTransaction().commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			SessionFactory.closeSession();
		}

	}

	public Session getSession() {
		return SessionFactory.getSession();
	}

}